Skip to content

feat(tools): add soroban multi-network config loader, tests, CLI verifier, and docs#13

Merged
ayshadogo merged 1 commit intoDfunder:mainfrom
OthmanImam:feat/Network
Feb 20, 2026
Merged

feat(tools): add soroban multi-network config loader, tests, CLI verifier, and docs#13
ayshadogo merged 1 commit intoDfunder:mainfrom
OthmanImam:feat/Network

Conversation

@OthmanImam
Copy link
Copy Markdown
Contributor

Closes: #4

Summary

Adds a deterministic, strongly-typed Soroban network configuration system that resolves the
active network from environment variables and soroban.toml profiles, with clear error
handling, unit tests, and a small CLI verifier.

Files changed

  • Added: soroban.toml
  • Added: .env.example
  • Added: crates/tools/src/config.rs (typed loader, errors, and tests)
  • Updated: crates/tools/Cargo.toml (deps)
  • Updated: crates/tools/src/main.rs (CLI network command)
  • Updated: README.md (docs snippet)

What it does

  • Implements Config::load() with resolution order:
    1. Environment variables: SOROBAN_NETWORK, SOROBAN_RPC_URL, SOROBAN_NETWORK_PASSPHRASE
    2. Profile selected in soroban.toml (testnet, mainnet, sandbox, or custom)
    3. Fail with typed ConfigError when ambiguous or missing required values
  • Provides Network enum and a strongly-typed Config struct for use by deployment
    scripts and tests.
  • CLI verifier: cargo run -p stellaraid-tools -- network prints:
    • Active network:
    • RPC URL:
    • Passphrase:

Tests & verification

Included unit tests under crates/tools:

  • loads_profile_by_name — profile resolution (testnet)
  • env_overrides_profile_values — env vars override profile
  • missing_required_values_returns_error — fails with typed error if required values missing
  • loads_sandbox_profile — sandbox profile

Run locally:

cargo test -p stellaraid-tools
cargo run -p stellaraid-tools -- network

Rationale

  • Keeps this crate focused on resolving and exposing effective configuration; relies on the
    official Soroban CLI for editing/managing soroban.toml.
  • Uses dotenvy, serde + toml, and thiserror for robust parsing and structured errors.
  • Tests isolate environment loading to avoid flakiness and ensure determinism.

Notes for reviewer

  • The loader searches upward from the current working directory for soroban.toml.
    If a .env file sits adjacent to the chosen soroban.toml, it will be loaded (allowing
    project-local .env overrides).
  • .env.example contains no secrets and documents override behavior.
  • No configuration editing commands were added (per design decision).

Commit

  • 27335be — feat(tools): add soroban multi-network config loader, tests, CLI verifier, and docs

Next steps

To push and open a PR:

git push -u origin feat/Network
# then open a PR on GitHub with this description

@ayshadogo ayshadogo merged commit 6a8fbef into Dfunder:main Feb 20, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants